<?php
require_once(FRAMEWORK_DIR.'/external/PHPMailer/class.phpmailer.php');
require_once(FRAMEWORK_DIR.'/external/PHPMailer/class.smtp.php');
class MailSMTP
{
	
	public static function send($subject, $message){
        
        date_default_timezone_set('Asia/Saigon');
        
        if (!isset(Parameter::$params['EMAIL_SUPPORT'])){
            Parameter::loadAllParameters();		
        }   
        
        $to = Parameter::$params['EMAIL_SUPPORT'];
        
        $mail             = new PHPMailer();
        
        $mail->IsSMTP(); // telling the class to use SMTP
        //$mail->SMTPDebug  = 2;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only
        $mail->SMTPAuth   = true;                  // enable SMTP authentication
        $mail->SMTPSecure = "ssl";                 // sets the prefix to the servier
        $mail->Host       = Parameter::$params['SMTP_HOST'];      // sets GMAIL as the SMTP server
        $mail->Port       = Parameter::$params['SMTP_PORT'];                   // set the SMTP port for the GMAIL server
        $mail->Username   = Parameter::$params['SMTP_USER'];  // GMAIL username
        $mail->Password   = Parameter::$params['SMTP_PASS'];            // GMAIL password
        
        $mail->From		  = Parameter::$params['EMAIL_SUPPORT'];
        
        $mail->Subject    = $subject;
        
        $mail->Body		  = $message;
        
        $address = $to;
        $mail->AddAddress($address);
        
        if(!$mail->Send()) {
           return false;
        } 
        return true;
	}	
}

?>